Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plural): add plural and select pipes #7268

Closed
wants to merge 1 commit into from
Closed

Conversation

kara
Copy link
Contributor

@kara kara commented Feb 25, 2016

@mhevery @vsavkin Review?

i18n plural pipe

Maps a value to a string that pluralizes the value properly.

Usage

expression | i18nPlural:mapping

where expression is a number and mapping is an object that indicates the proper text for
when the expression evaluates to 0, 1, or some other number. You can interpolate the actual
value into the text using the # sign.

Example

  <div [title]="messages.length | i18nPlural: messageMapping">
  </div>

  class MyApp {
    messages: any[];
    messageMapping: any = {
      '=0': 'No messages.',
      '=1': 'One message.',
      'other': '# messages.'
    }
    ...
  }

i18n select pipe

Generic selector that displays the string that matches the current value.

Usage

expression | i18nSelect:mapping

where mapping is an object that indicates the text that should be displayed for different values of the provided expression.

Example

  <div [title]="gender | i18nSelect: inviteMap">
  </div>

  class MyApp {
    gender: string = 'male';
    inviteMap: any = {
      'male': 'Invite her.',
      'female': 'Invite him.',
      'other': 'Invite them.'
    }
    ...
  }

@kara kara changed the title feat(ngPlural): add ng-plural and ng-select pipes feat(plural): add plural and select pipes Feb 25, 2016
@kara kara added the action: review The PR is still awaiting reviews from at least one requested reviewer label Feb 25, 2016
@CONST()
@Pipe({name: 'plural'})
@Injectable()
export class PluralPipe implements PipeTransform {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name suggestion I18nPluralPipe ???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works!

@mhevery mhevery added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 25, 2016
@kara kara force-pushed the ngplural branch 2 times, most recently from 828c59f to 86e580f Compare February 25, 2016 01:35
@kara kara added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Feb 25, 2016
@kara kara assigned mhevery and unassigned kara Feb 25, 2016
@kara
Copy link
Contributor Author

kara commented Feb 25, 2016

@mhevery I think I addressed all the comments. Let me know if there's anything else I should change!

@kara kara force-pushed the ngplural branch 2 times, most recently from 427cebd to ccc89d5 Compare February 25, 2016 02:08
import {Injectable, PipeTransform, Pipe} from 'angular2/core';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';

var interpolationExp: RegExp = RegExpWrapper.create('#');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it a const

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(we discussed and decided to leave as is)

@kara kara force-pushed the ngplural branch 2 times, most recently from 140b482 to 8f2b73c Compare February 25, 2016 02:55
@vsavkin vsavkin added pr_state: LGTM and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 26, 2016
@kara kara force-pushed the ngplural branch 2 times, most recently from bcd0290 to de34553 Compare February 26, 2016 18:02
@kara kara added the action: merge The PR is ready for merge by the caretaker label Feb 26, 2016
@mary-poppins
Copy link

Merging PR #7268 on behalf of @vsavkin to branch presubmit-vsavkin-pr-7268.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants